package com.findFish.water.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.findFish.common.annotation.Log;
import com.findFish.common.core.controller.BaseController;
import com.findFish.common.core.domain.AjaxResult;
import com.findFish.common.enums.BusinessType;
import com.findFish.water.domain.WaterFlow;
import com.findFish.water.service.IWaterFlowService;
import com.findFish.common.utils.poi.ExcelUtil;
import com.findFish.common.core.page.TableDataInfo;

/**
 * 水流与水位监测Controller
 * 
 * @author admin
 * @date 2025-04-01
 */
@RestController
@RequestMapping("/water/flow")
public class WaterFlowController extends BaseController
{
    @Autowired
    private IWaterFlowService waterFlowService;

    /**
     * 查询水流与水位监测列表
     */
    @PreAuthorize("@ss.hasPermi('water:flow:list')")
    @GetMapping("/list")
    public TableDataInfo list(WaterFlow waterFlow)
    {
        startPage();
        List<WaterFlow> list = waterFlowService.selectWaterFlowList(waterFlow);
        return getDataTable(list);
    }

    /**
     * 导出水流与水位监测列表
     */
    @PreAuthorize("@ss.hasPermi('water:flow:export')")
    @Log(title = "水流与水位监测", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WaterFlow waterFlow)
    {
        List<WaterFlow> list = waterFlowService.selectWaterFlowList(waterFlow);
        ExcelUtil<WaterFlow> util = new ExcelUtil<WaterFlow>(WaterFlow.class);
        util.exportExcel(response, list, "水流与水位监测数据");
    }

    /**
     * 获取水流与水位监测详细信息
     */
    @PreAuthorize("@ss.hasPermi('water:flow:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(waterFlowService.selectWaterFlowById(id));
    }

    /**
     * 新增水流与水位监测
     */
    @PreAuthorize("@ss.hasPermi('water:flow:add')")
    @Log(title = "水流与水位监测", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WaterFlow waterFlow)
    {
        return toAjax(waterFlowService.insertWaterFlow(waterFlow));
    }

    /**
     * 修改水流与水位监测
     */
    @PreAuthorize("@ss.hasPermi('water:flow:edit')")
    @Log(title = "水流与水位监测", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WaterFlow waterFlow)
    {
        return toAjax(waterFlowService.updateWaterFlow(waterFlow));
    }

    /**
     * 删除水流与水位监测
     */
    @PreAuthorize("@ss.hasPermi('water:flow:remove')")
    @Log(title = "水流与水位监测", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(waterFlowService.deleteWaterFlowByIds(ids));
    }
}
